/**
 * Created by cxl on 2017/2/26.
 */
window.onload=function () {
    $.ajax({
        type: 'get',
        url: 'http://192.168.23.81:3000/api/getproduct' + window.location.search,
        dataType: 'json',
        success: function (data) {
            // console.log(data);
            console.log(window.location.search);
            var html = template("template",data);
            $(".dianshi").html(">"+data.result[0].productName.split(" ")[0]);
            $(".main").html(html);
            var categoryId = data.result[0].categoryId;
            var productId=data.result[0].productId
            console.log(productId);
            $(".kehu").html(data.result[0].bjShop)
            $.ajax({
                type: 'get',
                url: 'http://192.168.23.81:3000/api/getcategorybyid?'+"categoryid="+categoryId,
                dataType: 'json',
                success:function (data) {
                    // console.log(data);
                   var  html=template("hui",data)
                    $("#category_name").html(html)
                    $.ajax({
                        type:'get',
                        url:'http://192.168.23.81:3000/api/getproductcom?'+"productid="+productId,
                        dataType:'json',
                        success:function (data) {
                            var html=template("pingjia",data)
                            $(".pingjia").html(html)
                        }
                    })
                }
            })
        }
    })
}